Page({
  data: {
    fake_course: [] , 
  },
  onLoad(options) {
  const getRandomLightColor = () => {
    const r = Math.floor(Math.random() * 170) + 300; // 55 到 255
    const g = Math.floor(Math.random() * 200) + 50; // 55 到 255
    const b = Math.floor(Math.random() * 200) + 55; // 55 到 255
    return `rgb(${r}, ${g}, ${b})`;
  };
  const courseColors = {};
  const courses = [
    { name: "英语", location: "4-4403", teacher: "张三" },
    {},
    {},
    {},
    {},
    {},
    { name: "数学", location: "4-4404", teacher: "李四" },
    { name: "物理", location: "4-4405", teacher: "王五" },
    { name: "化学", location: "4-4406", teacher: "赵六" },
    {},
    { name: "生物", location: "4-4407", teacher: "钱七" },
    {},
    { name: "历史", location: "4-4408", teacher: "孙八" },
    {},
    {},
    {},
    {},
    { name: "地理", location: "4-4409", teacher: "周九" }
  ];

  // 为每种课程分配颜色
  courses.forEach(course => {
    if (course.name && !courseColors[course.name]) {
      courseColors[course.name] = getRandomLightColor();
    }
    if (course.name) {
      course.color = courseColors[course.name];
    }
  });

  this.setData({
    fake_course: courses
  });
  },
  onReady() {

  },
  onShow() {

  },
  onHide() {

  },
  onUnload() {

  },
  onPullDownRefresh() {

  },
  onReachBottom() {

  },
  onShareAppMessage() {

  }
})